package site.marqstree.kotlin.usercenter.ui.activity.userinfo

import site.marqstree.kotlin.library.base.presenter.view.BasePresenter
import site.marqstree.kotlin.library.base.data.net.observer.RxObserver
import site.marqstree.kotlin.library.base.data.net.request.RxRequest
import site.marqstree.kotlin.library.base.extent.json2Bean
import site.marqstree.kotlin.provider.common.ProviderConstant
import site.marqstree.kotlin.usercenter.data.bean.EditUserBean
import javax.inject.Inject


/*
 * 项目名: KotlinMall
 * 包名: site.marqstree.kotlin.usercenter.presenter
 * 文件名: UserInfoPresenter
 * 创建者: marqstree
 * 创建时间: 2020/2/23 9:34
 * 描述: TODO
 */
/*
    编辑用户资料Presenter
 */
class UserInfoPresenter @Inject constructor() : BasePresenter<UserInfoView>() {

    /*
        编辑用户资料
     */
    fun editUser(id:String,userIcon:String,userName:String,userGender:String,userSign:String){

        RxRequest.builder()
            .setUrl(ProviderConstant.EDIT_USER_INFO_URL)
            .setParam("id",id)
            .setParam("icon",userIcon)
            .setParam("name",userName)
            .setParam("gender",userGender)
            .setParam("sign",userSign)
            .post()
            .json2Bean(EditUserBean::class.java)
            .subscribe(object :RxObserver<EditUserBean>(){
                override fun onNext(data: EditUserBean) {
                    mView.onEditUserResult(data.convert2UserInfo())
                }
            })

    }


}